public class Route {
    private static final int OCTETS_IN_ADDRESS = 4;
    private static final int OCTET_MAX_VALUE = 255;
    private Network network;
    private IPv4Address gateway;
    private String interfaceName;
    int metric;

    public Route(Network network, String gateway, String interfaceName, int metric) throws InvalidIpAddressException {
        this.network = network;
        this.gateway = new IPv4Address(gateway);
        this.interfaceName = interfaceName;
        this.metric = metric;
    }

    public String getGateway() {
        return this.gateway.toString();
    }

    public String getInterfaceName() {
        return this.interfaceName;
    }

    public int getMetric() {
        return this.metric;
    }

    public Network getNetwork() {
        return this.network;
    }

    @Override
    public String toString() {
        String gateway = (this.gateway == null) ? "" : ", gateway: " + this.gateway;

        return "net: " + this.network.toString() + gateway + ", interface: " + this.interfaceName + ", metric:" + this.metric;
    }
}
